<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('新增网格配置')"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-gridManage-add">
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">法人机构：</label>
            <div class="col-sm-8">
                <select name="deptId" id="deptId" class="form-control m-b"
                        th:with="type=${@dept.selectDeptListByType('2')}"
                        required>
                    <option value="">请选择</option>
                    <option th:each="dept : ${type}" th:text="${dept.deptName}" th:value="${dept.deptId}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <input name="gridCode" th:value="${gridCode}" class="form-control" type="hidden">
            <label class="col-sm-3 control-label is-required">网格名称：</label>
            <div class="col-sm-8">
                <input name="gridName" th:value="${gridName}" class="form-control" type="text" readonly>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">管理人：</label>
            <div class="col-sm-8">
                <div class="input-group">
                    <input name="userId" id="userId" type="hidden">
                    <input name="userName" id="userName" class="form-control" onclick="choiceUser()" type="text"
                           required>
                    <span class="input-group-addon"><i class="fa fa-search"></i></span>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">状态：</label>
            <div class="col-sm-8">
                <select name="sts" class="form-control m-b"
                        th:with="type=${@dict.getType('sys_sts')}" required>
                    <option value="">请选择</option>
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"
                    ></option>
                </select>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var prefix = ctx + "config/gridManage"
    $("#form-gridManage-add").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/add", $('#form-gridManage-add').serialize());
        }
    }

    /* 选择人员 */
    function choiceUser() {
        var url = prefix + "/choiceUser";
        var options = {
            title: '选择人员',
            width: "800",
            height: "600",
            url: url,
            callBack: doSubmit
        };
        $.modal.openOptions(options);
    }

    function doSubmit(index, layero) {
        var body = $.modal.getChildFrame(index);
        var userId = body.find('#userId').val();
        var userName = body.find('#userName').val();
        $("#userId").val(userId);
        $("#userName").val(userName);
        $.modal.close(index);
    }
</script>
</body>
</html>